﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DataPreperation
{
    [Serializable]
    public class GradedDB
    {
        // the items of the db represented by <ID, TMScore, Text> tuple
        public List<Tuple<string, double, string>> items { get; set; }
        public Dictionary<ItemPair, double> CosSim { get; set; }


        public GradedDB()
        {
            items = new List<Tuple<string, double, string>>();
            CosSim = new Dictionary<ItemPair, double>();
        }

        //returns the cosine similarity between two items
        public double GetSimilarity(IItem item1, IItem item2)
        {
            ItemPair p = new ItemPair(item1, item2);
            return CosSim[p];
        }

    }



    [Serializable]
    public class ItemPair
    {
        IItem item1;
        IItem item2;

        public ItemPair(IItem i, IItem j)
        {
            if (string.Compare(i.GetID(), j.GetID()) < 0)
            {
                item1 = i;
                item2 = j;
            }
            else
            {
                item1 = j;
                item2 = i;
            }
        }
    }
}
